<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
</head>
<body>
<form class="x-so" action="/userser/list" id="myform">

    <select id="condition" name="condition" style="width: 100px;height: 37px">
        <option value="----">----</option>
        <option value="编号">编号</option>
        <option value="用户名">用户名</option>
        <option value="服务类型">服务类型</option>
        <option value="经理">经理</option>
    </select>
    <input class="layui-input" name="conValue" th:value="${vv}" type="text" placeholder="请输入查询条件" id="conValue">
    <input type="button" class="layui-btn layui-btn-normal" value="查询" onclick="search()">
    <a id="dlink"  style="display:none;"></a>
    <input type="button" class="layui-btn layui-btn-normal" onclick="tableToExcel('tables', 'name', 'myfile.xls')" value="导出">

</form>



<table class="layui-table" id="tables">
        <thead>
        <th>反馈编号</th>
        <th>用户名</th>
        <th>客户姓名</th>
        <th>服务编号</th>
        <th>经理</th>
        <th>处理人</th>
        <th>服务类型</th>
        <th>服务日期</th>
        <th>客户联系方式</th>
        <th>预估成本</th>
        <th>服务时间</th>
        <th>内容描述</th>
        <th>经理是否已读</th>
        <th>客户反馈意见</th>
        <th>客户满意度</th>
        <th>完成时间</th>
        <th>操作</th>

        </thead>
        <tbody>
        <tr th:each="i:${info.list}">
            <td th:text="${i.resultId}"></td>
            <td th:text="${i.serUserNickName}"></td>
            <td th:text="${i.serName}"></td>
            <td th:text="${i.serId}"></td>
            <td th:text="${i.serManager}"></td>
            <td th:text="${i.resultManager}"></td>
            <td th:text="${i.serType}"></td>
            <td th:text="${i.serTime}"></td>
            <td th:text="${i.serUserTel}"></td>
            <td th:text="${i.serSpendMoney}"></td>
            <td th:text="${i.serSpendTime}"></td>
            <td th:text="${i.serContent}"></td>
            <td th:text="${i.serRead}"></td>
            <td th:text="${i.resultUserBack}"></td>
            <td th:text="${i.resultUsereVal}"></td>
            <td th:text="${i.resultTimei}"></td>
            <td>
                <button class="layui-btn layui-btn-normal" type="button" onclick="update(this)">完成</button>
                <button class="layui-btn layui-btn-normal" type="button" onclick="delUser(this)">删除</button>


            </td>
        </tr>
        </tbody>
    </table>
<div style="margin-top: 20px" class="x-so">
    <a class="layui-btn layui-btn-normal" th:href="@{/userser/list(page=${info.pre})}">上一页</a>
    <a class="layui-btn layui-btn-normal" th:href="@{/userser/list(page=${info.next})}">下一页</a>
    一共有<span th:text="${info.total}"></span>条数据
    一共有<span th:text="${info.totalPage}"></span>页
   当前第<span th:text="${info.cur}"></span>页

</div>



</body>
</html>
<script>
    //打开修改页面的方法
    function update(obj) {

        //获取当前选中行的userID值
        var id =$(obj).parent().parent().find("td").eq(0).text();
        //打开弹窗
        x_admin_show("修改","/userser/editpage?resultId="+id,800,500);

    }
    //删除
    function delUser(obj) {
        //获取当前选中行的userID值
        var id =$(obj).parent().parent().find("td").eq(0).text();
        //layui的提示框确定用户是否删除
        layer.confirm("你确定要删除吗？",{icon:3,title:"警告"},function (index) {
            $.ajax({
                url:"/userser/del",
                type:"get",
                data:{"resultId":id},
                dataType:"json",
                success:function (data) {
                    layer.alert(data.info)
                    if(data.info=="删除成功" && data.info1=="删除成功"){
                        //第一种刷新页面
                         parent.window.location.href=parent.window.location.href;
                        //第二种刷新
                        $(obj).parent().parent().remove();

                    }
                    layui.close(index);
                }

            })
        })
    }
    function add(obj) {

        //获取当前选中行的userID值
        var id =$(obj).parent().parent().find("td").eq(0).text();
        //打开弹窗
        x_admin_show("修改","/user/addpage?userId="+id,500,410);

    }
    function search() {
        //获取用户输入的查询条件
        var v = $("#conValue").val();
        var con = $("#condition").val();
        //判断用户输入的查询条件是什么
        if(con=="编号"){
            //创建一个正则表达式对象
            var re = /^[0-9]*$/;
            //验证用户输入的信息是否数字
            if(re.test(v)){
                document.getElementById("myform").submit();

            }else{
                layer.alert("请输入数字");

            }
        }else{
            //用js做表单提交
            document.getElementById("myform").submit();
        }
    }
    //excle导出
    var tableToExcel = (function () {
        var uri = 'data:application/vnd.ms-excel;base64,',
            template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
            base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) },
            format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) };
        return function (table, name, filename) {
            if (!table.nodeType) table = document.getElementById(table)
            var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }

            document.getElementById("dlink").href = uri + base64(format(template, ctx));
            document.getElementById("dlink").download = filename;
            document.getElementById("dlink").click();
        }
    })()

</script>